// Copyright 2024 The Google Research Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* Proto defining the format of messages exchanged by the client and servers.

EvaluationRequest: sent by the client to servers. Client communicates current
                   input for the blackbox function as a base vector around which
                   servers/workers will conduct perturbations to evaluate
                   blackbox function in the neighborhood of a base vector.

EvaluationResponse: sent by servers to the client. Each server is sending the
                    list of chosen perturbation directions and the corresponding
                    list of function values (function is evaluated at a base
                    vector perturbed by the perturbation vectors).

The Vanilla versions are for debugging, without perturbations.
*/

syntax = "proto3";

package third_party.google_research.google_research.es_maml.zero_order;

message Vector {
  repeated double values = 1;
}

message VectorInt {
  repeated int32 int_values = 1;
}

message EvaluationVanillaRequest {
  Vector current_input = 1;
  repeated double hyperparameters = 2;
  int32 tag = 4;
}

message EvaluationVanillaResponse {
  repeated double function_values = 1;
  repeated double evaluation_stats = 2;
  int32 tag = 3;
}

message EvaluationRequest {
  Vector current_input = 1;
  repeated double hyperparameters = 2;
  repeated Vector perturbations = 3;
  int32 tag = 4;
  int32 additional_data = 5;
  repeated string metadata = 6;
}

message EvaluationResponse {
  repeated Vector perturbations = 1;
  repeated double function_values = 2;
  repeated double evaluation_stats = 3;
  int32 tag = 4;
}

message Verification {
  bool finished = 1;
}

/*
 This service method takes as an input the request from the client given as a
 current input vector for the optimization and returns the list of perturbation
 directions together with the corresponding blackbox function values.
*/
service Evaluation {
  // Returns evaluated perturbations for a given sets of input perturbations
  // sent for evaluation.
  rpc EvaluateBlackboxInput(EvaluationRequest) returns (EvaluationResponse) {}
}
